package com.zhyt.intelligentpipeline.exception;

//import com.sun.xml.internal.ws.api.model.ExceptionType;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletResponse;

@RestControllerAdvice
public class ExceptionHandlerAdvice {

    @ExceptionHandler(CustomException.class)
    public ResponseEntity handleCommonException(CustomException e) {
        return ResponseEntity
                .status(e.getHttpStatus() != null ? e.getHttpStatus() : HttpStatus.BAD_REQUEST)
                .body(CommonErrorDTO.of(e));
    }
}
